import { Layout } from '@/utils/routerHelper'

const { t } = useI18n()

//@formatter:off
/**
 redirect: noredirect             当设置 noredirect 的时候该路由在面包屑导航中不可被点击
 name:'router-name'               设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 meta : {
     hidden: true                   当设置 true 的时候该路由不会在侧边栏出现 如404，login等页面(默认 false)
    
     alwaysShow: true               当一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式，
                                    只有一个时，会将那个子路由当做根路由显示在侧边栏，
                                    若你想不管路由下面的 children 声明的个数都显示你的根路由，
                                    你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
                                    (默认 false)
    
     title: 'title'                 设置该路由在侧边栏和面包屑以及页面子标题中展示的名字
    
     icon: 'svg-name'               设置该路由的图标
    
     noCache: false                 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    
     breadcrumb: true               如果设置为false，则不会在breadcrumb面包屑中显示(默认 true)
    
     affix: false                   如果设置为true，则会一直固定在tag项中(默认 false)
    
     noTagsView: false              如果设置为true，则不会出现在tag中(默认 false)
    
     activeMenu: '/dashboard'       显示高亮的路由路径
    
     followAuth: '/dashboard'       跟随哪个路由进行权限过滤
    
     canTo: false                   设置为true即使hidden为true，也依然可以进行路由跳转(默认 false)
 }
 **/
//@formatter:on

// [***]本地路由名称不要与服务端菜单配置中的路由名称冲突

// 参与路由与菜单渲染
export const constantRoutes: AppRouteRecordRaw[] = [
  {
    path: '/redirect',
    component: Layout,
    name: 'D_RedirectParent',
    children: [
      {
        path: '/redirect/:path(.*)',
        name: 'Redirect',
        component: () => import('@/views/base/redirect/Redirect.vue'),
        meta: { noCache: true }
      }
    ],
    meta: {
      hidden: true,
      noTagsView: true
    }
  },
  {
    path: '/404',
    component: () => import('@/views/base/error/404.vue'),
    name: 'NotFound', // 不需要keep_alive的页面的路由名称不需要与组件名保持一致
    meta: {
      hidden: true,
      title: '404',
      noTagsView: true
    }
  },
  {
    path: '/403',
    component: () => import('@/views/base/error/403.vue'),
    name: 'NoAccess',
    meta: {
      hidden: true,
      title: '403',
      noTagsView: true
    }
  },
  {
    path: '/500',
    component: () => import('@/views/base/error/500.vue'),
    name: 'Error',
    meta: {
      hidden: true,
      title: '500',
      noTagsView: true
    }
  },
  {
    path: '/login',
    component: () => import('@/views/base/login/Login.vue'),
    name: 'Login',
    meta: {
      hidden: true,
      title: t('router.login'),
      noTagsView: true
    }
  },
  {
    path: '/social-login',
    component: () => import('@/views/base/login/SocialLogin.vue'),
    name: 'SocialLogin',
    meta: {
      hidden: true,
      title: t('router.login'),
      noTagsView: true
    }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    name: 'D_Index',
    meta: {},
    children: [
      {
        path: 'index',
        component: () => import('@/views/base/home/index.vue'),
        name: 'Home',
        meta: {
          title: t('router.home'),
          icon: 'ep:home-filled',
          noCache: false,
          affix: true
        }
      }
    ]
  },
  // {
  //   path: '/demo',
  //   component: Layout,
  //   redirect: 'noRedirect',
  //   name: 'D_Demo',
  //   meta: {
  //     // hidden: true,
  //     title: '演示模块',
  //   },
  //   children: [
  //     {
  //       path: 'form-create-demo1',
  //       name: 'FormCreateDemo1',
  //       component: () => import('@/views/base/other/FormCreateDemo1.vue'),
  //       meta: {
  //         title: '表单演示1',
  //         activeName: '/index',
  //       }
  //     },
  //     {
  //       path: 'form-create-demo2',
  //       name: 'FormCreateDemo2',
  //       component: () => import('@/views/base/other/FormCreateDemo2.vue'),
  //       meta: {
  //         title: '表单演示2',
  //         activeName: '/index',
  //       }
  //     },
  //     {
  //       path: 'form-create-demo3',
  //       name: 'FormCreateDemo3',
  //       component: () => import('@/views/base/other/FormCreateDemo3.vue'),
  //       meta: {
  //         title: '表单演示3',
  //         activeName: '/index',
  //       }
  //     },
  //     {
  //       path: 'form-create-demo4',
  //       name: 'FormCreateDemo4',
  //       component: () => import('@/views/base/other/FormCreateDemo4.vue'),
  //       meta: {
  //         title: '表单演示4',
  //         activeName: '/index',
  //       }
  //     },
  //     {
  //       path: 'form-designer-demo1',
  //       name: 'FcDesignerDemo1',
  //       component: () => import('@/views/base/other/FcDesignerDemo1.vue'),
  //       meta: {
  //         title: '表单设计演示1',
  //         activeName: '/index',
  //       }
  //     },
  //   ]
  // },
  // {
  //   path: '/external-link',
  //   component: Layout,
  //   name: 'D_ExternalLink',
  //   meta: {
  //   },
  //   children: [
  //     {
  //       path: 'https://www.baidu.com',
  //       name: 'Baidu', // 不需要keep_alive的页面的路由名称不需要与组件名保持一致
  //       meta: {
  //         title: '百度',
  //         icon: 'ep:home-filled',
  //         noTagsView: true
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/iframe-link1',
  //   component: Layout,
  //   name: 'D_IframeLink1',
  //   meta: {
  //   },
  //   children: [
  //     {
  //       path: 'Baidu',
  //       name: 'Baidu', // 不需要keep_alive的页面的路由名称不需要与组件名保持一致
  //       meta: {
  //         title: '百度',
  //         icon: 'ep:home-filled',
  //         // noCache: true,
  //         link: 'https://lizard-api-test.neulive.net/doc.html'
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/iframe-link2',
  //   component: Layout,
  //   name: 'D_IframeLink2',
  //   meta: {
  //   },
  //   children: [
  //     {
  //       path: 'Sina',
  //       name: 'Sina', // 不需要keep_alive的页面的路由名称不需要与组件名保持一致
  //       meta: {
  //         title: '新浪',
  //         icon: 'ep:home-filled',
  //         // noCache: true,
  //         link: 'https://www.sina.com.cn'
  //       }
  //     }
  //   ]
  // },
  {
    path: '/user',
    component: Layout,
    redirect: 'noRedirect',
    name: 'D_User',
    meta: {
      hidden: true
    },
    children: [
      {
        path: 'profile',
        component: () => import('@/views/base/profile/index.vue'),
        name: 'Profile',
        meta: {
          title: t('common.profile'),
          icon: 'ep:user'
        }
      }
    ]
  },
  {
    path: '/:path(.*)*',
    component: () => import('@/views/base/error/404.vue'),
    name: '', // 这里不能有非空值
    meta: {
      title: '404',
      hidden: true,
      breadcrumb: false
    }
  }
]

// 仅参与路由
export const dynamicRoutes: AppRouteRecordRaw[] = [
  {
    path: '/system/dict-data',
    component: Layout,
    redirect: 'noRedirect',
    name: 'D_SystemDict',
    meta: {
      hidden: true
    },
    children: [
      {
        path: ':dictType', // 这里如果有类似于/system/dict-data/edit的更具体路由，只要定义在该动态路由前面即可，会优先匹配到
        component: () => import('@/views/system/dict/data/index.vue'),
        name: 'SystemDictData',
        permissions: ['system:dict:query'],
        meta: {
          title: t('router.dictData'),
          // noCache: true,   // 如何keepalive的话，会根据name与path搭配进行组件实例复用
          activeMenu: '/system/dict'
        }
      }
    ]
  },
  {
    path: '/infra/codegen',
    component: Layout,
    redirect: 'noRedirect',
    name: 'D_InfraCodegen',
    meta: {
      hidden: true
    },
    children: [
      {
        path: 'edit',
        component: () => import('@/views/infra/codegen/EditTable.vue'),
        name: 'InfraCodegenEditTable',
        permissions: ['infra:codegen:update'],
        meta: {
          title: '代码生成配置',
          noCache: true,
          activeMenu: '/infra/codegen/index'
        }
      }
    ]
  },
  {
    path: '/bpm',
    component: Layout,
    redirect: 'noRedirect',
    name: 'D_Bpm',
    meta: {
      hidden: true
    },
    children: [
      {
        path: 'manage/form/edit',
        component: () => import('@/views/bpm/form/FormEditor.vue'),
        name: 'BpmFormEditor',
        permissions: ['bpm:form:create', 'bpm:form:update'],
        meta: {
          title: '设计流程表单',
          noCache: true,
          activeMenu: '/bpm/manage/form'
        }
      },
      {
        path: 'manage/model/create',
        component: () => import('@/views/bpm/model/form/index.vue'),
        name: 'BpmModelCreate',
        permissions: ['bpm:model:create'],
        meta: {
          title: '创建流程',
          // noCache: true,
          activeMenu: '/bpm/manage/model'
        }
      },
      {
        path: 'manage/model/:type/:id',
        component: () => import('@/views/bpm/model/form/index.vue'),
        name: 'BpmModelUpdate',
        permissions: ['bpm:model:create', 'bpm:model:update'],
        meta: {
          title: '修改流程',
          // noCache: true,
          activeMenu: '/bpm/manage/model'
        }
      },
      {
        path: 'manage/definition/:key',
        component: () => import('@/views/bpm/model/definition/index.vue'),
        name: 'BpmProcessDefinition',
        meta: {
          title: '流程定义',
          // noCache: true, // 组件实例缓存
          activeMenu: '/bpm/manage/model'
        }
      },
      {
        path: 'process-instance/detail',
        component: () => import('@/views/bpm/processInstance/detail/index.vue'),
        name: 'BpmProcessInstanceDetail',
        meta: {
          title: '流程详情',
          noCache: true,
          activeMenu: '/bpm/task/my'
        },
        props: (route) => ({
          // 括号表示是return的对象，而不是方法的括号
          id: route.query.id,
          taskId: route.query.taskId,
          activityId: route.query.activityId
        })
      },
      {
        path: 'process-instance/report',
        component: () => import('@/views/bpm/processInstance/report/index.vue'),
        name: 'BpmProcessInstanceReport',
        meta: {
          // noCache: true,
          title: '数据报表',
          activeMenu: '/bpm/manage/model'
        }
      },
      {
        path: 'oa/leave/create',
        component: () => import('@/views/bpm/oa/leave/create.vue'),
        name: 'BpmOALeaveCreate',
        meta: {
          title: '发起请假申请',
          noCache: true,
          activeMenu: '/bpm/oa/leave'
        }
      },
      {
        path: 'oa/leave/detail',
        component: () => import('@/views/bpm/oa/leave/detail.vue'),
        name: 'BpmOALeaveDetail',
        meta: {
          title: '请假申请详情',
          noCache: true,
          activeMenu: '/bpm/oa/leave'
        }
      }
    ]
  },
  {
    path: '/ai',
    component: Layout,
    redirect: 'noRedirect',
    name: 'D_Ai',
    meta: {
      hidden: true
    },
    children: [
      {
        path: 'image/square',
        component: () => import('@/views/ai/image/square/index.vue'),
        name: 'AiImageSquare',
        meta: {
          title: '绘图作品',
          icon: 'ep:home-filled',
          noCache: false
        }
      },
      {
        path: 'knowledge/document',
        component: () => import('@/views/ai/knowledge/document/index.vue'),
        name: 'AiKnowledgeDocument',
        meta: {
          title: '知识库文档',
          icon: 'ep:document',
          noCache: false,
          activeMenu: '/ai/knowledge'
        }
      },
      {
        path: 'knowledge/document/create',
        component: () => import('@/views/ai/knowledge/document/form/index.vue'),
        name: 'AiKnowledgeDocumentCreate',
        meta: {
          title: '创建文档',
          icon: 'ep:plus',
          // noCache: true,
          hidden: true,
          activeMenu: '/ai/knowledge'
        }
      },
      {
        path: 'knowledge/document/update',
        component: () => import('@/views/ai/knowledge/document/form/index.vue'),
        name: 'AiKnowledgeDocumentUpdate',
        meta: {
          title: '修改文档',
          icon: 'ep:edit',
          // noCache: true,
          hidden: true,
          activeMenu: '/ai/knowledge'
        }
      },
      {
        path: 'knowledge/retrieval',
        component: () => import('@/views/ai/knowledge/knowledge/retrieval/index.vue'),
        name: 'AiKnowledgeRetrieval',
        meta: {
          title: '文档召回测试',
          icon: 'ep:search',
          // noCache: true,
          hidden: true,
          activeMenu: '/ai/knowledge'
        }
      },
      {
        path: 'knowledge/segment',
        component: () => import('@/views/ai/knowledge/segment/index.vue'),
        name: 'AiKnowledgeSegment',
        meta: {
          title: '知识库分段',
          icon: 'ep:tickets',
          // noCache: true,
          hidden: true,
          activeMenu: '/ai/knowledge'
        }
      },
    ]
  }
]
